package com.aierkeji.call.cms.controller;

import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aierkeji.call.cms.contants.Contants;
import com.aierkeji.call.cms.service.AkjCallEnterpriseService;
import com.aierkeji.call.cms.util.ResultMapHelper;

@RestController
@RequestMapping("/enterprise")
public class AkjCallEnterpriseController {
	private final Logger log = LogManager.getLogger(getClass());
	@Autowired
	AkjCallEnterpriseService akjCallEnterpriseService;

	@PostMapping("/list/{pageNo}")
	@RequiresRoles(value = { Contants.ROLE_ID_MANAGER, Contants.ROLE_ID_ADMIN }, logical = Logical.OR)
	public Map<String, Object> list(@PathVariable("pageNo") int pageNo,@RequestBody  Map<String,Object> map) {
		return akjCallEnterpriseService.findEnterpriseByCreatedBy(pageNo,map);
	}

	@PostMapping("/edit/{id}")
	@RequiresRoles(value = { Contants.ROLE_ID_MANAGER, Contants.ROLE_ID_ADMIN }, logical = Logical.OR)
	public Map<String, Object> edit(@PathVariable("id") Long id ,@RequestBody Map<String,Object> map) {
		return akjCallEnterpriseService.edit(id,map);
	}
	
	@PostMapping("/add")
	@RequiresRoles(value = { Contants.ROLE_ID_MANAGER }, logical = Logical.OR)
	public Map<String, Object> edit(@RequestBody Map<String,Object> map) {
		return akjCallEnterpriseService.add(map);
	}


}
